package com.qezhhnjy.mall.coupon.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.coupon.SkuBounds;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.coupon.service.SkuBoundsService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 商品sku积分设置 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "商品sku积分设置接口")
@Slf4j
@RequestMapping("/sku-bounds")
public class SkuBoundsController {
    @Resource
    private SkuBoundsService skuBoundsService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取商品sku积分设置信息")
    public BaseResult<SkuBounds> get(Long id) {
        SkuBounds skuBounds = skuBoundsService.getById(id);
        return BaseResult.success(skuBounds);
    }

    @PostMapping("/save")
    @Operation(summary = "新增商品sku积分设置信息")
    public BaseResult<SkuBounds> save(@RequestBody SkuBounds skuBounds) {
        skuBoundsService.save(skuBounds);
        return BaseResult.success(skuBounds);
    }

    @PutMapping("/update")
    @Operation(summary = "更新商品sku积分设置信息")
    public BaseResult<SkuBounds> update(@RequestBody SkuBounds skuBounds) {
        skuBoundsService.updateById(skuBounds);
        return BaseResult.success(skuBounds);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取商品sku积分设置信息")
    public BaseResult<Page<SkuBounds>> page(@RequestBody Page<SkuBounds> page) {
        skuBoundsService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除商品sku积分设置信息")
    public BaseResult<Long> delete(Long id) {
        skuBoundsService.removeById(id);
        return BaseResult.success(id);
    }
}

